<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hui</title>
    <link rel="stylesheet" type="text/css" href="../css/app.css" />
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
    

    <style type="text/css">
    </style>
</head>
<body>
    <div>


        <div class="H-theme-background-color-white H-margin-vertical-top-10 H-border-vertical-both-after">
            <div onclick="" tapmode="" class="H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-both-after H-vertical-middle H-touch-active">
	            <div class="H-flex-item H-padding-horizontal-both-8">头像</div>
	            <div class="H-padding-horizontal-left-10 H-padding-vertical-both-5"><img id="portrait" src="../../image/touxiang.jpg" class="H-height-50 H-vertical-align-middle H-width-50 H-border-radius-circle"></div>
	            
	            <span class="H-icon H-padding-horizontal-right-10 H-display-block"><i class="H-iconfont H-icon-arrow-right H-theme-font-color-999 H-font-size-14 H-vertical-middle"></i></span>
	        </div>
       
            
        </div>
        
        <div class="H-margin-vertical-top-10 H-theme-background-color-white H-border-vertical-both-after" >
            <div  onclick="" class="H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-bottom-margin-left-10-after H-vertical-middle H-touch-active">
                <div class="H-flex-item H-padding-horizontal-both-10 H-font-size-16 H-padding-vertical-both-12">昵称</div>
                <div class="nickname H-padding-horizontal-left-10 H-padding-vertical-both-5"></div>
	            
                <span class="H-icon H-padding-horizontal-right-10 H-display-block"><i class="H-iconfont H-icon-arrow-right H-theme-font-color-999 H-font-size-14 H-vertical-middle"></i></span>
            </div>
        </div>
        
        
       <!-- <div class="H-margin-vertical-top-10 H-theme-background-color-white H-border-vertical-both-after" >
            <div  onclick="edit_password();" class="H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-bottom-margin-left-10-after H-vertical-middle H-touch-active">
                <div class="H-flex-item H-padding-horizontal-both-10 H-font-size-16 H-padding-vertical-both-12">修改密码</div>
                <span class="H-icon H-padding-horizontal-right-10 H-display-block"><i class="H-iconfont H-icon-arrow-right H-theme-font-color-999 H-font-size-14 H-vertical-middle"></i></span>
            </div>
        </div>
        <div class="H-margin-vertical-bottom-10 H-theme-background-color-white H-border-vertical-both-after" >
            <div  onclick="edit_phone();" class="H-text-list H-flexbox-horizontal  H-theme-background-color-white H-border-vertical-bottom-margin-left-10-after H-vertical-middle H-touch-active">
                <div class="H-flex-item H-padding-horizontal-both-10 H-font-size-16 H-padding-vertical-both-12">绑定手机号</div>
                <span class="H-icon H-padding-horizontal-right-10 H-display-block"><i class="H-iconfont H-icon-arrow-right H-theme-font-color-999 H-font-size-14 H-vertical-middle"></i></span>
            </div>
        </div>-->
        <div class="H-padding-vertical-bottom-10"></div>
        

    </div>

	<script src="../script/jquery-1.12.0.min.js" type="text/javascript"></script>
	<script src="../script/api.js" type="text/javascript"></script>
	<script src="../script/app.js" type="text/javascript"></script>
	
    
    <script type="text/javascript">


		apiready = function(){
		
			var appVersion = api.appVersion; // 比如: 1.0.0
			$("#appVersion").html(appVersion);

//			$("#portrait").attr('src',"../image/a9.jpg");
			
			api.addEventListener({
			    name:'push_user_info'
			}, function(ret, err){        
			   
			});
			
			username = localStorage.getItem('username');
			token    = localStorage.getItem('token');
			portrait = localStorage.getItem('portrait');
			if(  typeof username != 'undefined' ){
				$(".nickname").text(username);
			}
			
			if(  typeof portrait != 'undefined' ){
				$("#portrait").attr( 'src' , portrait);
			}
			
			
			
		}
	
		
		
		function _openWinHead(name,url,title){
			uid = localStorage.getItem('uid');
			if(uid !='' && uid!=null  && uid!='undefined'){
				
				$app.openWinByUrl(name+'win_head','../win_head',{'fname':name,'furl':url,'title':title});
			}else{
				$app.openWinByUrl('login','../login');
			}
			
			
		}
		
		
		var portrait="";
		function touxiang(){
			api.actionSheet({
				title: '请选择方式',
				cancelTitle: '取消',
				 allowEdit:true, 
				buttons:['相机','相册']
			}, function(ret, err) {
				var index = ret.buttonIndex;
				if(index ==1){
					var sourceType = 'camera';
				}
				if(index ==2){
					var sourceType = 'album';
				}
				
				if(index ==3){
					return ;
				}
				
				var uid = localStorage.getItem('uid');
				var token = localStorage.getItem('token');
				api.getPicture({
					sourceType : sourceType,
					encodingType : 'jpg',
					destinationType : 'url',
					targetWidth : 500,
					targetHeight : 500,
					saveToPhotoAlbum: false
				}, function(ret, err) {
					if (ret) {
						
						if (ret.data != null && ret.data != "unfefined" && ret.data != "") {
							api.showProgress({
							    title: '正在上传...',
							    modal: false
							});
							
							$app.ajax($app.serverUrl +"Upload/uploadPortrait",{},'post',function(data){
								if( data.status =='1000'){
									portrait =  data.data.savepath +  data.data.savename ; 
									//更新用户头像
									$app.ajax($app.serverUrl +"User/saveUserInfo",{'uid':uid,'token':token,'portrait':portrait},"post",function(result){
										if(result.status ==1){
											$app.toast(result.info,function(){
												localStorage.setItem('portrait',result.data);
												api.sendEvent({
		                                            name:'event_userinfo'
	                                            });
												$("#portrait").attr('src',result.data);
											})	
										}else{
											$app.toast(result.info);
										}
										
									});
								}
								
								api.hideProgress();
								
							},'json',{'file':ret.data});
						}
					}else{
						//_toast(ret.info);
					}
				});
			});
			
		}
		
	
        
		
		
    </script>
</body>
</html>